import time

from selenium.webdriver.common.by import By
from Base.Base import Base
from Page.Boss import Boss
from Tools.Tools import Tools

'''账户管理页面'''
class AccountInfo(Boss):
    def __init__(self, driver):
        super().__init__(driver)
        self.logger = Tools().get_logger("Page.AccountInfo")

    # 点击账户信息
    account_info_loc =(By.XPATH,'/html/body/div[1]/div[2]/div[2]/div[2]/div[4]/ul/li[1]/div/a')
    def account_info(self):
        self.click(self.account_info_loc)

    # 输入账户编号
    account_id_loc = (
    By.XPATH, '/html/body/div[1]/div[3]/div/div[2]/div[2]/div[1]/form/div/table/tbody/tr/td[1]/input')


    def account_id(self,id):
        self.send_keys(self.account_id_loc,id)
    # 点击查询
    queryBtn_loc = (By.XPATH,'/html/body/div[1]/div[3]/div/div[2]/div[2]/div[1]/form/div/table/tbody/tr/td[2]/div/div/button')
    def query_click(self):
        self.click(self.queryBtn_loc)

    # 参数数据驱动
    def query_account_params(self,id):
        time.sleep(1)
        self.account_info()
        time.sleep(1)
        self.account_id(id)
        self.query_click()
    # 查询成功后，再次输入其他账户编号，查询成功
    def query_again(self):
        self.account_info()
        self.account_id('91733828182894952451')
        self.query_click()
        time.sleep(1)
        self.triple_click(self.account_id_loc)
        self.account_id('91733828091572371459')
        self.query_click()

    # 输入正确的账户编号，连续点击查询，查询成功
    def many_query(self):
        time.sleep(1)
        self.account_info()
        time.sleep(1)
        self.account_id('91733828182894952451')
        self.query_click()
        time.sleep(0.5)
        self.query_click()
        time.sleep(0.5)
        self.query_click()

    '''账户历史信息'''
    # 点击历史信息
    history_loc = (By.XPATH,'/html/body/div[1]/div[2]/div[2]/div[2]/div[4]/ul/li[2]/div/a')

    # 输入框
    history_id_loc = (By.XPATH,'/html/body/div[1]/div[3]/div/div[2]/div[2]/div[1]/form/div/table/tbody/tr/td[1]/input')

    # 查询按钮
    history_query_loc = (By.XPATH,'/html/body/div[1]/div[3]/div/div[2]/div[2]/div[1]/form/div/table/tbody/tr/td[2]/div/div/button')

    # 框中输入
    def history_id(self,id):
        self.send_keys(self.history_id_loc,id)

    # 点击历史信息
    def history(self):
        self.click(self.history_loc)
    # 点击查询按钮
    def history_query(self):
        self.click(self.history_query_loc)


    # 用例:跳转到历史信息
    def show_history(self):
        self.history()

    # 用例:切换到别的页面再切换历史信息
    def show_again_history(self):
        self.history()
        self.account_info()
        self.history()

    # 历史信息数据驱动
    def query_history_params(self, id):
        time.sleep(1)
        self.history()
        time.sleep(1)
        self.history_id(id)
        self.history_query()
